<?php

namespace core\traits;

use support\Response as SupportResponse;
use support\View;

trait UcView
{

    public function view(array $var = [], bool $frame = true): SupportResponse
    {
        $controller = get_controller();
        if (is_plugin()) {
            View::assign('template',   base_path() . '/template/uc/' . get_plugin() . '/' . mb_substr(get_controller(), 3) . '/' . request()->action . '.php');
        } else {
            View::assign('template',   base_path() . '/template/uc/frame/' . mb_substr($controller, 3) . '/' . request()->action . '.php');
        }

        if ($frame) {
            return raw_view('/template/uc/layout', $var, '', '');
        }
        return raw_view('/template/uc/noframelayout', $var, '', '');
    }
}
